using System;
using System.Collections.Generic;
using System.Text;
using Nicknames.Info;
using System.IO;
using System.Xml.Serialization;

namespace Nicknames.BusinessLogic
{
    public class XmlBuilder
    {
        public static string GetRequestAsXml(NicksRequestInfo nickRequest)
        {
            using (MemoryStream stream = new MemoryStream())
            {
                XmlSerializer serializer = new XmlSerializer(typeof(NicksRequestInfo));
                serializer.Serialize(stream, nickRequest);
                stream.Flush();
                byte[] buffer = stream.GetBuffer();
                stream.Close();
                return System.Text.Encoding.UTF8.GetString(buffer);
            }
        }
    }
}
